Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase formula coverage. #388

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Increase formula coverage. #388

merged 2 commits into from
Sep 12, 2024

Conversation

Laimiux
Copy link
Collaborator

@Laimiux Laimiux commented Sep 11, 2024

No description provided.

@carrotkite
Copy link

carrotkite commented Sep 11, 2024

1 Warning
⚠️ No coverage data found for com/instacart/formula/android/FragmentLifecycleCallback

JaCoCo Code Coverage 95.93% ✅

Class Covered Meta Status
com/instacart/formula/internal/ActionManager 100% 0%
com/instacart/formula/android/FragmentLifecycleCallback No coverage data found : -% No coverage data found : -% 🃏
com/instacart/formula/DeferredAction 100% 0%

Generated by 🚫 Danger

@Laimiux Laimiux force-pushed the laimonas/increase-coverage branch from 43418d7 to 5b0cc7b Compare September 11, 2024 19:15

private var removeListInvalidated: Boolean = false
private var scheduledForRemoval: MutableList<DeferredAction<*>>? = null
private var recomputeCheckToStartList: Boolean = false
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming these variables to have more descriptive names

}
scheduledToStart?.addAll(actionList)
for (action in actionList) {
if (!isRunning(action)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was poorly written as we were potentially adding to the list twice and checking isRunning() multiple times.

@Laimiux Laimiux force-pushed the laimonas/increase-coverage branch from 5b0cc7b to 905561b Compare September 11, 2024 20:52
@Laimiux Laimiux force-pushed the laimonas/increase-coverage branch from 905561b to 4c59783 Compare September 11, 2024 21:36
@@ -11,11 +11,11 @@ class DeferredAction<Event>(
) {
private var cancelable: Cancelable? = null

internal var listener: (Event) -> Unit = initial
internal var listener: ((Event) -> Unit)? = initial
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of setting empty lambda when disabling this, I made it nullable and set it to null.

@Laimiux Laimiux force-pushed the laimonas/increase-coverage branch from cd86b15 to e912f72 Compare September 12, 2024 14:39
@Laimiux Laimiux requested a review from deesonpatel September 12, 2024 14:49
observer.input(false)
observer.input(true)
observer.input(false)
observer.output { assertThat(this).isEqualTo(0) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the output value be equal to 2?

true - state (0) + 1
false - state = 1
true - state (1) + 1
false - state = 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, this is why the test name + comment are describing the situation

// TODO: I'm not sure if this is the right behavior
@Test
fun `action termination events are ignored`()

@Laimiux Laimiux merged commit 9a9a62f into master Sep 12, 2024
4 checks passed
@Laimiux Laimiux deleted the laimonas/increase-coverage branch September 12, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants